package com.benson.effective.builder;

public class NutritionFacts {

	private final int serviceSize;
	private final int servings;
	private final int calories;
	private final int fat;
	private final int sodium;
	private final int carbohydrate;
	
	public static class Builder{
		private final int serviceSize;
		private final int servings;
		
		private int calories;
		private int fat;
		private int sodium;
		private int carbohydrate;
		
		public Builder(int serviceSize,int servings){
			this.serviceSize = serviceSize;
			this.servings = servings;
		}

		public Builder setCalories(int calories) {
			this.calories = calories;
			return this;
		}

		public Builder setFat(int fat) {
			this.fat = fat;
			return this;
		}

		public Builder setSodium(int sodium) {
			this.sodium = sodium;
			return this;
		}

		public Builder setCarbohydrate(int carbohydrate) {
			this.carbohydrate = carbohydrate;
			return this;
		}
		
		public NutritionFacts build(){
			return new NutritionFacts(this);
		}
	}
	
	private NutritionFacts(Builder builder){
		this.calories = builder.calories;
		serviceSize = builder.serviceSize;
		servings = builder.serviceSize;
		fat =builder.serviceSize;
		sodium =builder.serviceSize;
		carbohydrate=builder.serviceSize;
	}
	
	public static void main(String[] args) {
		NutritionFacts n = new NutritionFacts.Builder(1, 0).setCalories(2).
				setCarbohydrate(1).setFat(0).build();
	}
}
